package com.esri.core.internal.tasks.e;

import java.io.Serializable;
import java.util.Stack;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;

/* loaded from: classes.dex */
public class a extends DefaultHandler implements Serializable {
    public static boolean a = false;
    private static final long serialVersionUID = 1;
    protected Stack<String> b = new Stack<>();
    private String c = null;

    @Override // org.xml.sax.helpers.DefaultHandler, org.xml.sax.ContentHandler
    public void startElement(String str, String str2, String str3, Attributes attributes) {
        String a2 = a(str, str2, str3);
        this.b.push(a2);
        if ("ServiceExceptionReport".equals(a2)) {
            this.c = "";
        } else if (this.c != null) {
            a(attributes);
        }
    }

    @Override // org.xml.sax.helpers.DefaultHandler, org.xml.sax.ContentHandler
    public void endElement(String str, String str2, String str3) {
        String pop = this.b.pop();
        pop.equals(a(str, str2, str3));
        if ("ServiceExceptionReport".equals(pop)) {
            String str4 = this.c;
            this.c = null;
            throw new RuntimeException(str4);
        }
    }

    @Override // org.xml.sax.helpers.DefaultHandler, org.xml.sax.ContentHandler
    public void characters(char[] cArr, int i, int i2) {
        String trim = new String(cArr, i, i2).trim();
        if (this.c != null) {
            a(trim);
        }
    }

    private void a(Attributes attributes) {
        String a2 = a(attributes, "code");
        if (a2 != null) {
            this.c += "code:" + a2 + ";";
        }
    }

    private void a(String str) {
        this.c += str + ";";
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public String a(String str, String str2, String str3) {
        return "".equals(str) ? str3 : str2;
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public static String a(Attributes attributes, String str) {
        if (attributes != null) {
            for (int i = 0; i < attributes.getLength(); i++) {
                if (attributes.getLocalName(i).equals(str)) {
                    return attributes.getValue(i);
                }
            }
        }
        return null;
    }

    public static String[] a(Attributes attributes, String... strArr) {
        String[] strArr2 = new String[strArr.length];
        if (attributes != null) {
            for (int i = 0; i < strArr.length; i++) {
                int i2 = 0;
                while (true) {
                    if (i2 >= attributes.getLength()) {
                        break;
                    } else if (attributes.getLocalName(i2).equals(strArr[i])) {
                        strArr2[i] = attributes.getValue(i2);
                        break;
                    } else {
                        i2++;
                    }
                }
            }
        }
        return strArr2;
    }
}
